package com.huang.A01_case;

import java.util.Scanner;

/**
 * 目标
 * 完成评委打分案例
 */
public class Demo3 {
    public static void main(String[] args) {
        System.out.println(getScore(6));
    }
    public static double getScore(int number){
        //定义动态数组存放评委分数
        int[] scores = new int[number];
        //for循环遍历 录入评委分数
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请输入第" + (i + 1) + "个评委的分数:");
            int score = sc.nextInt();
            scores[i] = score;
        }
        //记录总和
        int sum = 0;
        //记录最大值
        int max = scores[0];
        //记录最小值
        int min = scores[0];

        //遍历求值
        for (int i = 0; i < scores.length; i++) {
            int score = scores[i];
            //总和
            sum += score;
            //最大值
            if(score > max){
                max = score;
            }
            //最小值
            if(score < min){
                min = score;
            }
        }
        return 1.0 * (sum - max - min) / (number - 2);
    }
}